#include "StdAfx.h"
#include "sa_TwSpriteMore.h"

sa_TwSpriteMore::sa_TwSpriteMore(void):
d3dspt(0),
sprite(0)
{
}

sa_TwSpriteMore::~sa_TwSpriteMore(void)
{
}

void sa_TwSpriteMore::InitGraphics()
{
	D3DXCreateSprite(g_Render->GetDevice(), &d3dspt);    // create the Direct3D Sprite object

	D3DXCreateTextureFromFileEx(g_Render->GetDevice(),    // the device pointer
		(LPCSTR)"Panel2.png",    // the new file name
		D3DX_DEFAULT,    // default width
		D3DX_DEFAULT,    // default height
		D3DX_DEFAULT,    // no mip mapping
		NULL,    // regular usage
		D3DFMT_A8R8G8B8,    // 32-bit pixels with alpha
		D3DPOOL_MANAGED,    // typical TwMemory handling
		D3DX_DEFAULT,    // no filtering
		D3DX_DEFAULT,    // no mip filtering
		D3DCOLOR_XRGB(255, 0, 255),    // the hot-pink color key
		NULL,    // no image info struct
		NULL,    // not using 256 colors
		&sprite);    // load to sprite


}

void sa_TwSpriteMore::InitRenderState()
{

}

void sa_TwSpriteMore::InitLight()
{

}

void sa_TwSpriteMore::Update()
{

}

void sa_TwSpriteMore::Render()
{
	// clear the window to a bright red
	g_Render->GetDevice()->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 0, 0), 1.0f, 0);

	g_Render->GetDevice()->BeginScene();    // begins the 3D scene

	d3dspt->Begin(D3DXSPRITE_ALPHABLEND);    // // begin sprite drawing with transparency

	// draw the sprite
	D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);    // center at the upper-left corner
	D3DXVECTOR3 position(50.0f, 50.0f, 0.0f);    // position at 50, 50 with no depth
	d3dspt->Draw(sprite, NULL, &center, &position, D3DCOLOR_ARGB(127, 255, 255, 255));

	d3dspt->End();    // end sprite drawing

	g_Render->GetDevice()->EndScene();    // ends the 3D scene

	g_Render->GetDevice()->Present(NULL, NULL, NULL, NULL);


}

void sa_TwSpriteMore::Clear()
{
	sprite->Release();
}